#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <set>

using namespace std;

int CalculateProperDivisorSum(int p_num);

int main (int argc, char** argv)
{
	int t;
	
	scanf("%d", &t);
	
	for(int i = 0; i < t; i++)
	{
		int num;
	
		scanf("%d" , &num);
		
		//CalculateProperDivisorSum(num);
		printf("%d\n" , CalculateProperDivisorSum(num));
	}
	
	return 0;
}

int CalculateProperDivisorSum(int p_num)
{
	int n = 1;

	vector<int> primeDivisors;
	
	int squareRoot = (int) sqrt(p_num);
	
	while(n < squareRoot + 1)
	{
		if (p_num % n == 0)
		{
			primeDivisors.push_back(n);
		}
		
		n++;
	}
	
	set<int> divisors;
	
	for (int i = 0; i < primeDivisors.size(); ++i)
	{
		for (int j = i; j < primeDivisors.size(); ++j)
		{
			divisors.insert(primeDivisors[i] * primeDivisors[j]);
		}
	}

	int sum = 0;
	
	for (set<int>::iterator it = divisors.begin() ; it != divisors.end(); it++ )
	{
		sum += (*it);
	}

	return sum;
}